﻿@model AntUnion.FrameWork.Model.Models.Mt5User
@{
    ViewData["Title"] = "Create";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <script type="text/javascript">
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , parentFrameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引;

            /**多语言初始化 */
            top.SetFormPageLanguage(layui);
            $('#passwordType').append(new Option(top.lang.pleaseSelect, ""));
            $('#passwordType').append(new Option(top.lang.userPassMain, "userPassMain"));
            $('#passwordType').append(new Option(top.lang.userPassInvestor, "userPassInvestor"));
            layui.form.render("select");

            /* 监听提交 */
            form.on('submit(submit-form)', function (data) {
                if (data.field.passwordType.length <= 0) {
                    top.AlertByKey(layui, "pleaseSelectPasswordType", 0);
                    return false;
                }
                var text = top.lang.confirmResetTransactionPwd;
                if (data.field.passwordType === "userPassMain") {
                    text = top.lang.confirmResetTransactionPwd;
                } else if (data.field.passwordType === "userPassInvestor") {
                    text = top.lang.confirmReadonlyTransactionPwd;
                }
                var postData = {
                    "Id": data.field.Id,
                    "updateType": data.field.passwordType
                };
                layui.layer.confirm(text, {
                    title: top.lang.resetPassword,
                    btn: [top.lang.confirmBtn, top.lang.closeBtn]
                }, function (index, layero) {
                    $.ajax({
                        type: "POST",
                        url: "/Console/MT5Users/UpdatePwd",
                        data: postData, // 你的formid
                        async: true,
                        error: function (request) {
                            alert("Connection error");
                        },
                        beforeSend: function (xhr) {
                            layui.layer.load();
                        },
                        success: function (data) {
                            var item = eval(data);
                            if (item.code == 0) {
                                /**提示语弹框 */
                                top.ShowMessageByKey(layui, item.data, 6, 1000, function () {
                                    parent.layer.close(parentFrameIndex);
                                    parent.renderTable();
                                });
                            } else {
                                /**提示语弹框 */
                                top.AlertByKey(layui, item.data, 0);
                            }
                            layer.closeAll('loading');
                        }
                    });
                });
                return false;
            });

        });
    </script>
}

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group">
                <div class="layui-form-item">
                    <label class="layui-form-label" lay-event="tradingAccountNo">交易账号</label>
                    <div class="layui-input-block">
                        <input type="text" id="Id" name="Id" value="@Model.Login" disabled="disabled" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" lay-event="passwordType">密码类型</label>
                    <div class="layui-input-block">
                        <select name="passwordType" id="passwordType">
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button id="submitForm" class="layui-btn" lay-submit="" lay-filter="submit-form">立即提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>